<?php

class Speed extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'yii_speeds':
	 * @var integer $id
	 * @var string $name
	 * @var integer $world_in
	 * @var integer $world_out
	 * @var integer $ukraine_in
	 * @var integer $ukraine_out
	 * @var integer $active
	 * @var string $change_time
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{speeds}}';
	}
	
	public function scopes()
	{
		return array(
			'active'=>array(
				'condition'=>'t.active=1',
				'order'=>'t.id',
			),
		);
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, change_time', 'required'),
			array('world_in, world_out, ukraine_in, ukraine_out, active', 'numerical', 'integerOnly'=>true),
			array('name', 'length', 'max'=>60),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => Yii::t('speed', 'Id'),
			'name' => Yii::t('speed', 'Name'),
			'world_in' => Yii::t('speed', 'World In'),
			'world_out' => Yii::t('speed', 'World Out'),
			'ukraine_in' => Yii::t('speed', 'Ukraine In'),
			'ukraine_out' => Yii::t('speed', 'Ukraine Out'),
			'active' => Yii::t('speed', 'Active'),
			'change_time' => Yii::t('speed', 'Change Time'),
		);
	}
}